package com.edu.exam.enums.assessment;

/**
 * 推荐类型枚举
 */
public enum RecommendationType {
    ACCEPT("ACCEPT", "接受"),
    REJECT("REJECT", "拒绝"),
    MODIFY("MODIFY", "修改"),
    REVIEW("REVIEW", "复核"),
    IGNORE("IGNORE", "忽略"),
    ESCALATE("ESCALATE", "上报"),
    APPROVE("APPROVE", "批准"),
    IMPROVE("IMPROVE", "改进"),
    REPLACE("REPLACE", "替换"),
    MERGE("MERGE", "合并");

    private final String code;
    private final String description;

    RecommendationType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static RecommendationType fromCode(String code) {
        if (code == null || code.trim().isEmpty()) {
            return REVIEW;
        }
        for (RecommendationType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return REVIEW;
    }

    public static RecommendationType fromDescription(String description) {
        if (description == null || description.trim().isEmpty()) {
            return REVIEW;
        }
        for (RecommendationType type : values()) {
            if (type.getDescription().equals(description)) {
                return type;
            }
        }
        return REVIEW;
    }

    @Override
    public String toString() {
        return this.code + "(" + this.description + ")";
    }
}